package cn.javass.framework.web.util;

import java.lang.reflect.Proxy;

import cn.javass.framework.aop.interceptor.ProxyFactory;
import cn.javass.framework.ioc.annotation.IService;
import cn.javass.framework.web.annotation.IAction;

public class ClassUtils {
	public static Object getSource(Object o) {
		if (Proxy.isProxyClass(o.getClass())) {
			o = ((ProxyFactory) Proxy.getInvocationHandler(o)).getSource();
		}
		return o;
	}

	public static String getId(Object obj) {
		String id = null;
		if (obj.getClass().isAnnotationPresent(IService.class)) {
			id = obj.getClass().getAnnotation(IService.class).id();
		} else {
			id = obj.getClass().getAnnotation(IAction.class).path();
		}
		return id;
	}
}
